<template>
  <div>
    <!-- $nextTick:等到它前面的数据渲染完成后执行它的回调方法 -->
    <div ref="div">{{ num }}</div>
    <button @click="numAdd">修改num</button>
  </div>
</template>
<script>
export default {
  data () {
    return {
      num: 0
    }
  },
  methods: {
    numAdd () {
      this.num++
      this.$nextTick(() => {
        console.log(this.$refs.div.innerText) // 0   1
      })
    }
  }
}
</script>
<style></style>
